{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 特征工程\n",
    "import pandas as pd\n",
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
      "0        1  2011-01-01       1   0     1        0        6           0   \n",
      "1        2  2011-01-02       1   0     1        0        0           0   \n",
      "2        3  2011-01-03       1   0     1        0        1           1   \n",
      "3        4  2011-01-04       1   0     1        0        2           1   \n",
      "4        5  2011-01-05       1   0     1        0        3           1   \n",
      "\n",
      "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
      "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
      "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
      "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
      "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
      "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
      "\n",
      "    cnt  \n",
      "0   985  \n",
      "1   801  \n",
      "2  1349  \n",
      "3  1562  \n",
      "4  1600  \n",
      "731    1\n",
      "251    1\n",
      "249    1\n",
      "248    1\n",
      "247    1\n",
      "246    1\n",
      "245    1\n",
      "244    1\n",
      "243    1\n",
      "242    1\n",
      "241    1\n",
      "240    1\n",
      "239    1\n",
      "238    1\n",
      "237    1\n",
      "236    1\n",
      "235    1\n",
      "234    1\n",
      "233    1\n",
      "232    1\n",
      "231    1\n",
      "250    1\n",
      "252    1\n",
      "229    1\n",
      "253    1\n",
      "272    1\n",
      "271    1\n",
      "270    1\n",
      "269    1\n",
      "268    1\n",
      "      ..\n",
      "466    1\n",
      "465    1\n",
      "464    1\n",
      "463    1\n",
      "462    1\n",
      "461    1\n",
      "460    1\n",
      "479    1\n",
      "480    1\n",
      "481    1\n",
      "492    1\n",
      "500    1\n",
      "499    1\n",
      "498    1\n",
      "497    1\n",
      "496    1\n",
      "495    1\n",
      "494    1\n",
      "493    1\n",
      "491    1\n",
      "482    1\n",
      "490    1\n",
      "489    1\n",
      "488    1\n",
      "487    1\n",
      "486    1\n",
      "485    1\n",
      "484    1\n",
      "483    1\n",
      "1      1\n",
      "Name: instant, Length: 731, dtype: int64\n",
      "2011-04-03    1\n",
      "2011-07-06    1\n",
      "2011-05-22    1\n",
      "2012-08-06    1\n",
      "2012-03-11    1\n",
      "2011-01-28    1\n",
      "2012-03-26    1\n",
      "2012-03-22    1\n",
      "2012-01-23    1\n",
      "2011-10-06    1\n",
      "2011-04-18    1\n",
      "2011-08-05    1\n",
      "2011-09-28    1\n",
      "2011-11-18    1\n",
      "2012-11-05    1\n",
      "2012-04-30    1\n",
      "2012-02-16    1\n",
      "2012-03-14    1\n",
      "2011-02-28    1\n",
      "2012-11-19    1\n",
      "2011-09-17    1\n",
      "2011-02-23    1\n",
      "2011-09-11    1\n",
      "2011-11-08    1\n",
      "2011-09-06    1\n",
      "2012-02-27    1\n",
      "2011-08-21    1\n",
      "2011-11-22    1\n",
      "2012-07-14    1\n",
      "2012-02-24    1\n",
      "             ..\n",
      "2012-05-08    1\n",
      "2011-02-10    1\n",
      "2012-12-01    1\n",
      "2012-08-26    1\n",
      "2011-01-04    1\n",
      "2012-09-28    1\n",
      "2011-07-03    1\n",
      "2012-01-27    1\n",
      "2012-12-13    1\n",
      "2012-10-31    1\n",
      "2012-03-29    1\n",
      "2012-05-16    1\n",
      "2011-10-02    1\n",
      "2012-10-16    1\n",
      "2011-07-30    1\n",
      "2011-05-31    1\n",
      "2011-08-02    1\n",
      "2012-12-24    1\n",
      "2012-01-09    1\n",
      "2011-05-09    1\n",
      "2012-04-10    1\n",
      "2012-08-31    1\n",
      "2011-10-07    1\n",
      "2011-10-23    1\n",
      "2011-10-17    1\n",
      "2012-06-27    1\n",
      "2011-03-09    1\n",
      "2011-12-30    1\n",
      "2012-09-09    1\n",
      "2011-06-15    1\n",
      "Name: dteday, Length: 731, dtype: int64\n",
      "3    188\n",
      "2    184\n",
      "1    181\n",
      "4    178\n",
      "Name: season, dtype: int64\n",
      "1    366\n",
      "0    365\n",
      "Name: yr, dtype: int64\n",
      "12    62\n",
      "10    62\n",
      "8     62\n",
      "7     62\n",
      "5     62\n",
      "3     62\n",
      "1     62\n",
      "11    60\n",
      "9     60\n",
      "6     60\n",
      "4     60\n",
      "2     57\n",
      "Name: mnth, dtype: int64\n",
      "0    710\n",
      "1     21\n",
      "Name: holiday, dtype: int64\n",
      "6    105\n",
      "1    105\n",
      "0    105\n",
      "5    104\n",
      "4    104\n",
      "3    104\n",
      "2    104\n",
      "Name: weekday, dtype: int64\n",
      "1    500\n",
      "0    231\n",
      "Name: workingday, dtype: int64\n",
      "1    463\n",
      "2    247\n",
      "3     21\n",
      "Name: weathersit, dtype: int64\n",
      "0.265833    5\n",
      "0.635000    5\n",
      "0.437500    4\n",
      "0.564167    4\n",
      "0.649167    4\n",
      "0.484167    4\n",
      "0.680000    4\n",
      "0.696667    4\n",
      "0.710833    4\n",
      "0.514167    3\n",
      "0.282500    3\n",
      "0.667500    3\n",
      "0.459167    3\n",
      "0.554167    3\n",
      "0.733333    3\n",
      "0.636667    3\n",
      "0.606667    3\n",
      "0.342500    3\n",
      "0.731667    3\n",
      "0.653333    3\n",
      "0.393333    3\n",
      "0.530000    3\n",
      "0.343333    3\n",
      "0.414167    3\n",
      "0.353333    3\n",
      "0.577500    3\n",
      "0.775000    3\n",
      "0.715833    3\n",
      "0.274167    3\n",
      "0.550000    3\n",
      "           ..\n",
      "0.834167    1\n",
      "0.381667    1\n",
      "0.346667    1\n",
      "0.765833    1\n",
      "0.640833    1\n",
      "0.415833    1\n",
      "0.545000    1\n",
      "0.359167    1\n",
      "0.365833    1\n",
      "0.623333    1\n",
      "0.160870    1\n",
      "0.365217    1\n",
      "0.712500    1\n",
      "0.348696    1\n",
      "0.096522    1\n",
      "0.538333    1\n",
      "0.361667    1\n",
      "0.715000    1\n",
      "0.711667    1\n",
      "0.343478    1\n",
      "0.335833    1\n",
      "0.570000    1\n",
      "0.282609    1\n",
      "0.396667    1\n",
      "0.404167    1\n",
      "0.226957    1\n",
      "0.354167    1\n",
      "0.580833    1\n",
      "0.231667    1\n",
      "0.337500    1\n",
      "Name: temp, Length: 499, dtype: int64\n",
      "0.654688    4\n",
      "0.637008    3\n",
      "0.375621    3\n",
      "0.542929    2\n",
      "0.603554    2\n",
      "0.537896    2\n",
      "0.243058    2\n",
      "0.351629    2\n",
      "0.594704    2\n",
      "0.450121    2\n",
      "0.387608    2\n",
      "0.242400    2\n",
      "0.298422    2\n",
      "0.724121    2\n",
      "0.611121    2\n",
      "0.595346    2\n",
      "0.378779    2\n",
      "0.594083    2\n",
      "0.398350    2\n",
      "0.425492    2\n",
      "0.574500    2\n",
      "0.607962    2\n",
      "0.522721    2\n",
      "0.318812    2\n",
      "0.654042    2\n",
      "0.466525    2\n",
      "0.325750    2\n",
      "0.703292    2\n",
      "0.607975    2\n",
      "0.654054    2\n",
      "           ..\n",
      "0.326379    1\n",
      "0.565217    1\n",
      "0.228587    1\n",
      "0.497463    1\n",
      "0.338383    1\n",
      "0.255679    1\n",
      "0.542925    1\n",
      "0.513242    1\n",
      "0.533450    1\n",
      "0.565067    1\n",
      "0.445062    1\n",
      "0.647100    1\n",
      "0.513848    1\n",
      "0.355425    1\n",
      "0.645846    1\n",
      "0.412237    1\n",
      "0.116175    1\n",
      "0.274621    1\n",
      "0.707071    1\n",
      "0.188413    1\n",
      "0.323867    1\n",
      "0.456429    1\n",
      "0.150888    1\n",
      "0.761367    1\n",
      "0.461483    1\n",
      "0.612379    1\n",
      "0.464021    1\n",
      "0.624371    1\n",
      "0.512621    1\n",
      "0.538521    1\n",
      "Name: atemp, Length: 690, dtype: int64\n",
      "0.613333    4\n",
      "0.568333    3\n",
      "0.542500    3\n",
      "0.752917    3\n",
      "0.697083    3\n",
      "0.630833    3\n",
      "0.605000    3\n",
      "0.590000    3\n",
      "0.690000    3\n",
      "0.729583    3\n",
      "0.741250    3\n",
      "0.552083    3\n",
      "0.590417    3\n",
      "0.483333    3\n",
      "0.722917    3\n",
      "0.538333    3\n",
      "0.570000    3\n",
      "0.862500    2\n",
      "0.757500    2\n",
      "0.434167    2\n",
      "0.441250    2\n",
      "0.672917    2\n",
      "0.537917    2\n",
      "0.410000    2\n",
      "0.677500    2\n",
      "0.805833    2\n",
      "0.734583    2\n",
      "0.668750    2\n",
      "0.540833    2\n",
      "0.694167    2\n",
      "           ..\n",
      "0.642500    1\n",
      "0.422500    1\n",
      "0.494167    1\n",
      "0.616957    1\n",
      "0.700833    1\n",
      "0.640417    1\n",
      "0.187917    1\n",
      "0.414583    1\n",
      "0.559167    1\n",
      "0.691250    1\n",
      "0.581667    1\n",
      "0.561667    1\n",
      "0.720417    1\n",
      "0.896667    1\n",
      "0.838750    1\n",
      "0.797083    1\n",
      "0.426250    1\n",
      "0.457500    1\n",
      "0.618333    1\n",
      "0.609167    1\n",
      "0.812917    1\n",
      "0.810833    1\n",
      "0.537500    1\n",
      "0.712500    1\n",
      "0.704167    1\n",
      "0.615000    1\n",
      "0.686667    1\n",
      "0.480833    1\n",
      "0.649565    1\n",
      "0.741739    1\n",
      "Name: hum, Length: 595, dtype: int64\n",
      "0.228858    3\n",
      "0.118792    3\n",
      "0.134954    3\n",
      "0.149883    3\n",
      "0.166667    3\n",
      "0.110700    3\n",
      "0.136817    3\n",
      "0.167912    3\n",
      "0.106350    3\n",
      "0.116908    2\n",
      "0.342667    2\n",
      "0.157350    2\n",
      "0.144904    2\n",
      "0.121896    2\n",
      "0.146775    2\n",
      "0.102000    2\n",
      "0.130600    2\n",
      "0.296037    2\n",
      "0.215792    2\n",
      "0.361950    2\n",
      "0.131221    2\n",
      "0.122512    2\n",
      "0.266175    2\n",
      "0.140550    2\n",
      "0.118167    2\n",
      "0.063450    2\n",
      "0.133721    2\n",
      "0.168726    2\n",
      "0.230725    2\n",
      "0.236937    2\n",
      "           ..\n",
      "0.293961    1\n",
      "0.117562    1\n",
      "0.139308    1\n",
      "0.077125    1\n",
      "0.064071    1\n",
      "0.147392    1\n",
      "0.132467    1\n",
      "0.162938    1\n",
      "0.207721    1\n",
      "0.271158    1\n",
      "0.115522    1\n",
      "0.225754    1\n",
      "0.200875    1\n",
      "0.237567    1\n",
      "0.197763    1\n",
      "0.213009    1\n",
      "0.169779    1\n",
      "0.136926    1\n",
      "0.215804    1\n",
      "0.103863    1\n",
      "0.284829    1\n",
      "0.193417    1\n",
      "0.292287    1\n",
      "0.093921    1\n",
      "0.125621    1\n",
      "0.388067    1\n",
      "0.185333    1\n",
      "0.189667    1\n",
      "0.290421    1\n",
      "0.415429    1\n",
      "Name: windspeed, Length: 650, dtype: int64\n",
      "968     4\n",
      "120     4\n",
      "244     3\n",
      "653     3\n",
      "639     3\n",
      "123     3\n",
      "140     3\n",
      "163     3\n",
      "775     3\n",
      "692     2\n",
      "174     2\n",
      "178     2\n",
      "699     2\n",
      "695     2\n",
      "694     2\n",
      "1026    2\n",
      "190     2\n",
      "1077    2\n",
      "678     2\n",
      "676     2\n",
      "195     2\n",
      "673     2\n",
      "667     2\n",
      "665     2\n",
      "729     2\n",
      "745     2\n",
      "155     2\n",
      "2795    2\n",
      "349     2\n",
      "819     2\n",
      "       ..\n",
      "559     1\n",
      "560     1\n",
      "562     1\n",
      "563     1\n",
      "2613    1\n",
      "568     1\n",
      "569     1\n",
      "571     1\n",
      "2622    1\n",
      "579     1\n",
      "2634    1\n",
      "1612    1\n",
      "845     1\n",
      "1619    1\n",
      "1278    1\n",
      "1557    1\n",
      "599     1\n",
      "601     1\n",
      "603     1\n",
      "606     1\n",
      "2708    1\n",
      "1633    1\n",
      "611     1\n",
      "1088    1\n",
      "613     1\n",
      "614     1\n",
      "1639    1\n",
      "616     1\n",
      "620     1\n",
      "1118    1\n",
      "Name: casual, Length: 606, dtype: int64\n",
      "4841    3\n",
      "1707    3\n",
      "6248    3\n",
      "3578    2\n",
      "4429    2\n",
      "1730    2\n",
      "3848    2\n",
      "2115    2\n",
      "3840    2\n",
      "674     2\n",
      "1368    2\n",
      "1454    2\n",
      "3854    2\n",
      "2713    2\n",
      "4446    2\n",
      "5711    2\n",
      "3425    2\n",
      "3614    2\n",
      "4934    2\n",
      "3594    2\n",
      "3896    2\n",
      "1628    2\n",
      "4224    2\n",
      "3248    2\n",
      "4232    2\n",
      "3946    2\n",
      "2419    2\n",
      "5219    2\n",
      "4240    2\n",
      "5265    2\n",
      "       ..\n",
      "2697    1\n",
      "1672    1\n",
      "6790    1\n",
      "3717    1\n",
      "4739    1\n",
      "3714    1\n",
      "2688    1\n",
      "3185    1\n",
      "1432    1\n",
      "6803    1\n",
      "5780    1\n",
      "1687    1\n",
      "6911    1\n",
      "4790    1\n",
      "1714    1\n",
      "4750    1\n",
      "2733    1\n",
      "1708    1\n",
      "1705    1\n",
      "6433    1\n",
      "5124    1\n",
      "1689    1\n",
      "1700    1\n",
      "1699    1\n",
      "1697    1\n",
      "2720    1\n",
      "670     1\n",
      "1693    1\n",
      "4763    1\n",
      "4097    1\n",
      "Name: registered, Length: 679, dtype: int64\n",
      "5119    2\n",
      "4401    2\n",
      "1977    2\n",
      "6824    2\n",
      "5191    2\n",
      "1096    2\n",
      "5202    2\n",
      "5847    2\n",
      "5312    2\n",
      "4758    2\n",
      "6043    2\n",
      "5698    2\n",
      "1685    2\n",
      "6591    2\n",
      "4274    2\n",
      "4195    2\n",
      "3974    2\n",
      "6536    2\n",
      "4459    2\n",
      "6883    2\n",
      "7534    2\n",
      "1162    2\n",
      "2424    2\n",
      "2425    2\n",
      "3214    2\n",
      "4649    2\n",
      "5260    2\n",
      "4073    2\n",
      "2077    2\n",
      "4098    2\n",
      "       ..\n",
      "8156    1\n",
      "3709    1\n",
      "5905    1\n",
      "6779    1\n",
      "6778    1\n",
      "2710    1\n",
      "4727    1\n",
      "7393    1\n",
      "5743    1\n",
      "5463    1\n",
      "1712    1\n",
      "7282    1\n",
      "5786    1\n",
      "6830    1\n",
      "5805    1\n",
      "1708    1\n",
      "683     1\n",
      "6825    1\n",
      "2743    1\n",
      "4773    1\n",
      "3747    1\n",
      "3744    1\n",
      "1693    1\n",
      "3740    1\n",
      "4763    1\n",
      "6273    1\n",
      "5501    1\n",
      "4760    1\n",
      "1683    1\n",
      "4097    1\n",
      "Name: cnt, Length: 696, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "\n",
    "train = pd.read_csv(\"bike/day.csv\")\n",
    "print(train.head())\n",
    "# 观察哪些是类别型\n",
    "for col in list(train):\n",
    "    print(train[col].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   season_1  season_2  season_3  season_4  mnth_1  mnth_2  mnth_3  mnth_4  \\\n",
      "0         1         0         0         0       1       0       0       0   \n",
      "1         1         0         0         0       1       0       0       0   \n",
      "2         1         0         0         0       1       0       0       0   \n",
      "3         1         0         0         0       1       0       0       0   \n",
      "4         1         0         0         0       1       0       0       0   \n",
      "\n",
      "   mnth_5  mnth_6  ...  weathersit_1  weathersit_2  weathersit_3  weekday_0  \\\n",
      "0       0       0  ...             0             1             0          0   \n",
      "1       0       0  ...             0             1             0          1   \n",
      "2       0       0  ...             1             0             0          0   \n",
      "3       0       0  ...             1             0             0          0   \n",
      "4       0       0  ...             1             0             0          0   \n",
      "\n",
      "   weekday_1  weekday_2  weekday_3  weekday_4  weekday_5  weekday_6  \n",
      "0          0          0          0          0          0          1  \n",
      "1          0          0          0          0          0          0  \n",
      "2          1          0          0          0          0          0  \n",
      "3          0          1          0          0          0          0  \n",
      "4          0          0          1          0          0          0  \n",
      "\n",
      "[5 rows x 26 columns]\n"
     ]
    }
   ],
   "source": [
    "# 对类别型特征，转为object，才能被get_dummies处理，形成杜热编码\n",
    "categorical_features = ['season', 'mnth', 'weathersit', 'weekday']\n",
    "for col in categorical_features:\n",
    "    train[col] = train[col].astype('object')\n",
    "\n",
    "X_train_cat = train[categorical_features]\n",
    "X_train_cat = pd.get_dummies(X_train_cat)\n",
    "print(X_train_cat.head())\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "       temp     atemp       hum  windspeed\n",
      "0  0.355170  0.373517  0.828620   0.284606\n",
      "1  0.379232  0.360541  0.715771   0.466215\n",
      "2  0.171000  0.144830  0.449638   0.465740\n",
      "3  0.175530  0.174649  0.607131   0.284297\n",
      "4  0.209120  0.197158  0.449313   0.339143\n"
     ]
    }
   ],
   "source": [
    "# 最大值最小值标准化\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "mn_X = MinMaxScaler()\n",
    "numerical_features =['temp', 'atemp', 'hum', 'windspeed']\n",
    "temp = mn_X.fit_transform(train[numerical_features])\n",
    "# print(temp)\n",
    "X_train_num = pd.DataFrame(data=temp, columns=numerical_features, index=train.index)\n",
    "print(X_train_num.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   season_1  season_2  season_3  season_4  mnth_1  mnth_2  mnth_3  mnth_4  \\\n",
      "0         1         0         0         0       1       0       0       0   \n",
      "1         1         0         0         0       1       0       0       0   \n",
      "2         1         0         0         0       1       0       0       0   \n",
      "3         1         0         0         0       1       0       0       0   \n",
      "4         1         0         0         0       1       0       0       0   \n",
      "\n",
      "   mnth_5  mnth_6  ...  weekday_3  weekday_4  weekday_5  weekday_6      temp  \\\n",
      "0       0       0  ...          0          0          0          1  0.355170   \n",
      "1       0       0  ...          0          0          0          0  0.379232   \n",
      "2       0       0  ...          0          0          0          0  0.171000   \n",
      "3       0       0  ...          0          0          0          0  0.175530   \n",
      "4       0       0  ...          1          0          0          0  0.209120   \n",
      "\n",
      "      atemp       hum  windspeed  holiday  workingday  \n",
      "0  0.373517  0.828620   0.284606        0           0  \n",
      "1  0.360541  0.715771   0.466215        0           0  \n",
      "2  0.144830  0.449638   0.465740        0           1  \n",
      "3  0.174649  0.607131   0.284297        0           1  \n",
      "4  0.197158  0.449313   0.339143        0           1  \n",
      "\n",
      "[5 rows x 32 columns]\n"
     ]
    }
   ],
   "source": [
    "# 合在一起\n",
    "X_train = pd.concat([X_train_cat, X_train_num, train['holiday'], train['workingday']]\n",
    "                    ,axis=1, ignore_index=False)\n",
    "print(X_train.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   instant  season_1  season_2  season_3  season_4  mnth_1  mnth_2  mnth_3  \\\n",
      "0        1         1         0         0         0       1       0       0   \n",
      "1        2         1         0         0         0       1       0       0   \n",
      "2        3         1         0         0         0       1       0       0   \n",
      "3        4         1         0         0         0       1       0       0   \n",
      "4        5         1         0         0         0       1       0       0   \n",
      "\n",
      "   mnth_4  mnth_5  ...  weekday_5  weekday_6      temp     atemp       hum  \\\n",
      "0       0       0  ...          0          1  0.355170  0.373517  0.828620   \n",
      "1       0       0  ...          0          0  0.379232  0.360541  0.715771   \n",
      "2       0       0  ...          0          0  0.171000  0.144830  0.449638   \n",
      "3       0       0  ...          0          0  0.175530  0.174649  0.607131   \n",
      "4       0       0  ...          0          0  0.209120  0.197158  0.449313   \n",
      "\n",
      "   windspeed  holiday  workingday  yr   cnt  \n",
      "0   0.284606        0           0   0   985  \n",
      "1   0.466215        0           0   0   801  \n",
      "2   0.465740        0           1   0  1349  \n",
      "3   0.284297        0           1   0  1562  \n",
      "4   0.339143        0           1   0  1600  \n",
      "\n",
      "[5 rows x 35 columns]\n",
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 731 entries, 0 to 730\n",
      "Data columns (total 35 columns):\n",
      "instant         731 non-null int64\n",
      "season_1        731 non-null uint8\n",
      "season_2        731 non-null uint8\n",
      "season_3        731 non-null uint8\n",
      "season_4        731 non-null uint8\n",
      "mnth_1          731 non-null uint8\n",
      "mnth_2          731 non-null uint8\n",
      "mnth_3          731 non-null uint8\n",
      "mnth_4          731 non-null uint8\n",
      "mnth_5          731 non-null uint8\n",
      "mnth_6          731 non-null uint8\n",
      "mnth_7          731 non-null uint8\n",
      "mnth_8          731 non-null uint8\n",
      "mnth_9          731 non-null uint8\n",
      "mnth_10         731 non-null uint8\n",
      "mnth_11         731 non-null uint8\n",
      "mnth_12         731 non-null uint8\n",
      "weathersit_1    731 non-null uint8\n",
      "weathersit_2    731 non-null uint8\n",
      "weathersit_3    731 non-null uint8\n",
      "weekday_0       731 non-null uint8\n",
      "weekday_1       731 non-null uint8\n",
      "weekday_2       731 non-null uint8\n",
      "weekday_3       731 non-null uint8\n",
      "weekday_4       731 non-null uint8\n",
      "weekday_5       731 non-null uint8\n",
      "weekday_6       731 non-null uint8\n",
      "temp            731 non-null float64\n",
      "atemp           731 non-null float64\n",
      "hum             731 non-null float64\n",
      "windspeed       731 non-null float64\n",
      "holiday         731 non-null int64\n",
      "workingday      731 non-null int64\n",
      "yr              731 non-null int64\n",
      "cnt             731 non-null int64\n",
      "dtypes: float64(4), int64(5), uint8(26)\n",
      "memory usage: 70.0 KB\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# 合在一起\n",
    "X_train = pd.concat([X_train_cat, X_train_num, train['holiday'], train['workingday']]\n",
    "                    ,axis=1, ignore_index=False)\n",
    "# print(X_train.head())\n",
    "FE_train = pd.concat([train['instant'], X_train, train['yr'], train['cnt']]\n",
    "                     ,axis=1)\n",
    "print(FE_train.head())\n",
    "print(FE_train.info())\n",
    "FE_train.to_csv('bike_day_FE.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
